
#pragma once
// #include <stdio.h>
// #include <memory>
#include <list>
#include <string>
#include <vector>

#include "imgui.h"
#include "imgui_impl_sdl2.h"
#include "imgui_impl_sdlrenderer.h"
#include <SDL2/SDL.h>

#include "command.h"

void example_window();

class Window;

class ListWindows {
  public:
    static ListWindows &getInstance();
    void setWindow(Window *);
    std::list<Window *> getWindows();
    void erase(Window *);

    ~ListWindows();

  private:
    ListWindows();
    static std::list<Window *> windows;
};

// 窗口基类，需要显示的窗口继承该类
class Window {

  public:
    // Window();
    Window(Window *);
    virtual ~Window();
    virtual void Show();

  private:
    Window *mPointer;
};

// 控制台窗口
class Console : public Window {
  public:
    Console();
    ~Console();
    void Show();
    void ExecuteCommands(std::string cmd);

  private:
    bool checkParams(const std::vector<std::string> &, const Cmd_Map &standar);

  private:
    std::vector<std::string> InputTextItems;
};

class MediaPlayer : public Window {
  public:
    MediaPlayer();
    ~MediaPlayer();
    void Show();
    void Start(std::string);

  private:
    bool LoadTextureFromFile(std::string path, SDL_Texture *&, int *w, int *h);

  private:
    std::string mSourceName;
    SDL_Texture *mTextureId;
    int mWidth;
    int mHeight;
};

// 窗口主体
class MainWindow {
  public:
    MainWindow();
    ~MainWindow();
    int run();

  public:
    static SDL_Window *window;
    static SDL_Renderer *renderer;

  private:
    ImGuiIO *mIo;
    ImVec4 bg_color;
};
